<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * @author Anh Nguyen <duyanhnguyen@vccorp.vn>
 * @copyright 2012
 */

class Post extends MX_Controller
{
    
    private $_langCode;

    function __construct()
    {
        parent::__construct();
        $this->load->library('Layout');
        $this->_langCode = $this->mycommon->getLangCode();
        session_start();
        unset($_SESSION['search']);
    }
    
    public function index($id = '')
    {
        $data = array();
        if($id == '' || intval($id) == 0) 
            show_404 ();
        $this->load->model('post/post_model');
        $this->load->language('landing/landing', $this->_langCode);
        $langCode= $this->mycommon->fetchLangCode($this->_langCode);
        $tmpInfo = $this->post_model->getInfoById($id, $langCode);
        if (!$tmpInfo) {
            show_404();
        } else {
            $this->layout->setMenuActive($tmpInfo[0]['parent_id']);
            $data['postInfo'] = $tmpInfo[0];
            $data['lang'] = $this->lang->line('landing_lang');
            $data['headTitle'] = $tmpInfo['0']['title'];
            $tmpMorePost = $this->post_model->getMorePostWithType($id, $tmpInfo[0]['parent_id'], $langCode);
            $data['morePost'] = $tmpMorePost;
        }
        $this->layout->view('post/post_detail_view', $data);
    }

}

?>
